#ifndef __thinvm_ond__
#define __thinvm_ond__

#include "thinvm.h"
#include <algorithm>

namespace thinvm { namespace wkm {

	struct apidb_desc 
	{
		uint16_t	retn;
		uint16_t	attr;
#ifdef APIDB_WITH_NAME
		const char*	name;
#endif
	};

#ifdef APIDB_WITH_NAME
#	define	APINAME(x)		#x
#else
#	define	APINAME(x)	
#endif

	enum {	
		WKM_FUNCTION_LENGTH = 0x10 ,
		WKM_FUNCTION_OFFSET = 5,
	};

	size_t api_rva_to_index( uint32_t first_exp, uint32_t api_rva )
	{
		return (api_rva - first_exp)/WKM_FUNCTION_LENGTH;
	}

	//static bool ond_desc_less( const apidb_desc & left, const apidb_desc & right )
	//{
	//	return left.rva < right.rva;
	//}

	//static inline const apidb_desc * ond_find_desc( const apidb_desc * begin, size_t num, uint32_t rva )
	//{
	//	const apidb_desc * _last = begin + num;
	//	apidb_desc desc = { rva };
	//	const apidb_desc * hit = std::lower_bound( begin, _last, desc, ond_desc_less );
	//	if( hit == _last || hit->rva != rva ) return NULL;
	//	return hit;
	//}

	namespace kernel32
	{
#include "../wkm/kernel32.dll.apidb.h"
#include "../wkm/kernel32.dll.apiid.h"
#include "../wkm/kernel32.dll.wkm.h"
	};

} };

#endif